<template>
  <div class="mainBox">
    <div class="topBox">
      <span class="topTitle">签署中心</span>
      <div class="topContent">
        <div class="topContentItem" @click="gotoDetail('入职签署')">
          <div><img src="@/assets/image/cf/imgrz.png" alt="" /></div>
          <div class="font16" style="margin-top: -2px">入职签署</div>
        </div>
        <div class="topContentItem"  @click="gotoDetail('到期续签')">
          <div><img src="@/assets/image/cf/imgdq.png" alt="" /></div>
          <div class="font16" style="margin-top: -2px">到期续签</div>
        </div>
        <div class="topContentItem"  @click="gotoDetail('离职签署')">
          <div><img src="@/assets/image/cf/imglz2.png" alt="" /></div>
          <div class="font16" style="margin-top: -2px">离职签署</div>
        </div>
        <div class="topContentItem"  @click="gotoDetail('调岗签署')">
          <div><img src="@/assets/image/cf/imgtg.png" alt="" /></div>
          <div class="font16" style="margin-top: -2px">调岗签署</div>
        </div>
        <div class="topContentItem"  @click="gotoDetail('规章制度签署')">
          <div><img src="@/assets/image/cf/imggzzd.png" alt="" /></div>
          <div class="font16" style="margin-top: -2px">规章制度签署</div>
        </div>
        <div class="topContentItem"  @click="gotoDetail('自定义签署')">
          <div><img src="@/assets/image/cf/imgzdy.png" alt="" /></div>
          <div class="font16" style="margin-top: -2px">自定义签署</div>
        </div>
      </div>
    </div>
    <div class="bottomBox">
      <div class="bottomListBox">
        <div class="flex box-row">
          <div class="flex-1">
            <el-form ref="queryForm" :inline="true" class="mt10" :model="queryParams">
              <el-form-item label="员工状态">
                <el-select v-model="queryParams.job_status" placeholder="请选择状态" style="width: 200px; height: 36px">
                  <el-option v-for="item in jobstatusoptions" :key="item.value" :label="item.name" :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="员工姓名">
                <el-input v-model="queryParams.name" placeholder="请输入员工姓名" clearable style="width: 200px; height: 36px" />
              </el-form-item>
              <el-form-item label="入职时间">
                <el-date-picker
                  style="width: 200px; height: 36px"
                  v-model="queryParams.hired_time"
                  type="daterange"
                  range-separator="-"
                  format="YYYY/MM/DD"
                  value-format="YYYY-MM-DD"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                ></el-date-picker>
              </el-form-item>
              <el-form-item>
                <el-button style="width: 72px; height: 36px; font-size: 16px" type="primary" size="mini" color="#01509f" @click="handleQuery">搜索</el-button>
                <el-button style="width: 72px; height: 36px; font-size: 16px" @click="reset">重置</el-button>
              </el-form-item>
            </el-form>
          </div>
          <div>
            <el-button style="height: 36px; font-size: 16px" size="mini" @click="handleQuery" icon="folder-opened">导出</el-button>
          </div>
        </div>
        <div class="flex box-row mb20">
          <div :class="istaban === 1 ? 'table_anniu on' : 'table_anniu'" @click="">待我处理(1)</div>
          <div :class="istaban === 2 ? 'table_anniu on' : 'table_anniu'" @click="">我发起的(2)</div>
          <div :class="istaban === 3 ? 'table_anniu on' : 'table_anniu'" @click="">我收到的(2)</div>
          <div :class="istaban === 4 ? 'table_anniu on' : 'table_anniu'" @click="">未完成(2)</div>
          <div :class="istaban === 5 ? 'table_anniu on' : 'table_anniu'" @click="">已完成</div>
          <div :class="istaban === 5 ? 'table_anniu on' : 'table_anniu'" @click="">已失效(2)</div>
        </div>
        <el-table
          :data="list"
          border
          @selection-change="handleSelectionChange"
          v-loading="loading"
          element-loading-background="rgba(0, 0, 0, 0.5)"
          element-loading-text="加载中..."
          header-row-class-name="table-header"
        >
          <el-table-column label="任务主题" align="center" key="name" prop="name" />

          <el-table-column label="合同类型" width="200" align="center" key="id_card" prop="id_card" />
          <el-table-column label="时间" align="center" key="hired_time" prop="hired_time" />
          <el-table-column label="参与人" align="center" key="job_status" prop="job_status">
            <template #default="scope">
              <div class="flex box-row-column">
                <span>
                  <el-icon size="16" color="#01509f">
                    <clock />
                  </el-icon>
                  某某某
                </span>
                <span>
                  <i class="el-icon-time"></i>
                  某某
                </span>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="证书" align="center" key="job_status" prop="job_status">
            <template #default="scope">
              <div class="flex box-row-column">
                <span><el-icon>
  <document />
</el-icon>
      暂无证书</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="状态" align="center" key="insured_time" prop="insured_time" />


          <el-table-column label="操作" align="center"  fixed="right" width="330">
            <template #default="scope">
              <el-button style="font-size: 16px" text icon="View" @click="openHandle(scope.row)">查看</el-button>
              <el-button style="font-size: 16px;color: #ff4345" text icon="Delete" @click="openHandle(scope.row)">删除</el-button>
              <el-button style="font-size: 16px;color: #ff4345" text icon="circle-close" @click="openHandle(scope.row)">拒签</el-button>
              <el-button style="font-size: 16px" text icon="refresh-left" @click="openHandle(scope.row)">撤消</el-button>
            </template>
          </el-table-column>
        </el-table>
        <Pagination :total="total" :current-page="pageInfo.page" :page-size="pageInfo.limit" @pagination-change="handlePaginationChange" />
      </div>
    </div>
    <el-dialog v-model="open" title="登记" width="538" :before-close="handleClose">
      <el-form ref="ruleFormRef" label-position="right" label-width="130px" :model="form" class="form-inline">
        <el-form-item class="" label="员工：">
          <span v-if="!is_batch">{{ form.name }}</span>
          <span v-if="is_batch">已选择{{ checklist.length }}人</span>
        </el-form-item>
        <el-form-item class="" label="登记类型：">
          <el-radio-group v-model="form.insured_status">
            <el-radio :value="0">未参保</el-radio>
            <el-radio :value="1">正常参保</el-radio>
            <el-radio :value="2">已停保</el-radio>
            <el-radio :value="3">异常参保</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item class="" label="参保时间：" v-if="form.insured_status == 1">
          <el-date-picker v-model="form.insured_time" type="date" format="YYYY/MM/DD" value-format="YYYY-MM-DD" placeholder="请选择参保时间"></el-date-picker>
        </el-form-item>
        <el-form-item class="" label="停保时间：" v-if="form.insured_status == 2">
          <el-date-picker v-model="form.insured_stop_time" type="date" format="YYYY/MM/DD" value-format="YYYY-MM-DD" placeholder="请选择停保时间"></el-date-picker>
        </el-form-item>
        <el-form-item class="" label="备注：">
          <el-input v-model="form.insured_desc" style="width: 309px; height: 51px" :rows="2" type="textarea" placeholder="备注" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button size="small" @click="cancel">取消</el-button>
          <el-button type="primary" color="#01509f" size="small" @click="changeInfo">确认</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
<script setup lang="ts">
  import { ref, onMounted, onBeforeUnmount, computed } from "@/TUIKit/adapter-vue";
  import Pagination from "@/components/Pagination.vue";
  import type { ElMessage, ElMessageBox, UploadProps } from "element-plus";
  import { user_list } from "@/api/cf";
  import { insured_handle, insuredExport, insuredTotal } from "@/api/xl";
  import { exportFile } from "@/utils/format";
  import * as echarts from "echarts";
    import { useRouter } from "vue-router";
      const router = useRouter();
  const chartRef = ref(null);
  const uploadRef = ref(null);
  const queryParams = ref({ name: "", hired_time: "", job_status: "", insured_status: "" });
  const pageInfo = ref({ page: 1, limit: 10 });
  const loading = ref(false);
  const open = ref(false);
  const is_batch = ref(false);
  const total = ref(0);
  const form = ref({});
  const insuredTotalData = ref({});
  const list = ref([]);
  const token = localStorage.getItem("token");
  const checklist = ref([]);
  const checkedStatuslist = ref([0, 0, 0, 0, 0, 0]);
  const jobstatusoptions = ref([
    { value: "1", name: "试用" },
    { value: "2", name: "正式" },
    { value: "3", name: "待离职" },
    { value: "4", name: "离职" },
  ]);
  let chartInstance = null;


    function gotoDetail(a) {
   // router.push({ name: "qianshu", params: { id: 1, name:a, status: 0 } });
   router.push({ name: "qianshu", params: { id: 1, name:a, status: 0 } });
     //router.push({ name: "employeeInfo", params: { id: 0, name: "one", status: 0 } });
  }
  onMounted(() => {
    // getInsured();
    // // 监听窗口大小变化事件以支持响应式
    // window.addEventListener("resize", resizeChart);
    // getuser_list();
  });
  onBeforeUnmount(() => {

  });


   const  handleQuery = () => {
    console.log(queryParams.value);
 
  };
    const  reset = () => {
    queryParams.value = { name: "", hired_time: "", job_status: "", insured_status: "" };
  };  
</script>

<style lang="scss" scoped>
.cell .el-button {
  margin-left: 0px !important;
  padding: 8px 10px !important;
}

.el-table {
  font-size: 16px;
  /* 默认大小 */
}

/* 设置表头文字 */
.el-table th {
  font-size: 18px;
}

/* 设置表格内容文字 */
.el-table td {
  font-size: 16px;
}

.table_anniu {
  height: 30px;
  border: solid 1px #eaeaea;
  border-radius: 6px;
  color: #666666;
  font-size: 15px;
  line-height: 30px;
  text-align: center;
  padding: 0 12px;
  cursor: pointer;
  margin: 0 10px;
}

.table_anniu:hover {
  border-color: rgb(198, 226, 255);
  background-color: rgb(236, 245, 255);
  color: #409eff;
}

.table_anniu.on {
  border-color: #01509f;
  background-color: #01509f;
  color: #fff;
}

.mainBox {
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  // padding: 22px;
  // box-sizing: border-box;

  .topBox {
    background-color: #fff;
    border-radius: 12px;
    padding: 17px;
    box-sizing: border-box;

    .topTitle {
      font-size: 20px;
      font-weight: bolder;
      color: #333;
    }

    .topContent {
      display: flex;
      flex-direction: row;
      margin-top: 20px;
      gap: 30px;
      width: 100%;
      // padding: 17px 41px 0 41px;
      box-sizing: border-box;

      .topContentItem {
        display: flex;
        flex-direction: row;
        gap: 10px;
        align-items: center;
        border: solid 1px #e5e5e5;
        padding: 10px 10px;
        border-radius: 10px;
        box-sizing: border-box;
        flex-grow: 1;
        cursor: pointer;
        font-size: 15px;
      }

      .topContentItem:hover {
        background-color: #f7faff;
        border-color: #78aaff;
      }

      .zi3 {
        font-size: 16px;
      }

      .num_kuai {
        // width: 30%;
        margin-top: 10px;
        margin-right: 98px;
        text-align: center;
        cursor: pointer;
        transition: background-color 0.8s ease, transform 0.8s ease;
        will-change: background-color;
      }

      .checked {
        color: #fff;
        border-radius: 6px;
        padding: 6px 10px;
        width: 92px;
        height: 64px;
        box-sizing: border-box;

        .y1::before {
          display: none;
        }

        .y2::before {
          display: none;
        }

        .y3::before {
          display: none;
        }

        .y4::before {
          display: none;
        }

        .y5::before {
          display: none;
        }

        .y6::before {
          display: none;
        }
      }

      .zi_num {
        font-size: 24px;
        font-weight: bold;
      }

      .y1::before {
        content: "";
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: #1864f2;
        margin-right: 5px;
      }

      .y2::before {
        content: "";
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: #fe5c55;
        margin-right: 5px;
      }

      .y3::before {
        content: "";
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: #2ad4ae;
        margin-right: 5px;
      }

      .y4::before {
        content: "";
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: #ff7b43;
        margin-right: 5px;
      }

      .y5::before {
        content: "";
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: #9188e5;
        margin-right: 5px;
      }

      .y6::before {
        content: "";
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: #e5c388;
        margin-right: 5px;
      }
    }
  }

  .bottomBox {
    background-color: #fff;
    border-radius: 12px;
    padding: 17px;
    box-sizing: border-box;
    margin-top: 22px;

    .bottomTopBox {
      padding-bottom: 18px;
      display: flex;
      align-items: center;
      border-bottom: 1px solid #eaeaea;

      .bottomTitle {
        font-size: 20px;
        color: #333;
        font-weight: bolder;
        flex: 1;
      }

      .bottomRightBox {
        display: flex;
        align-items: center;

        .btnItem1 {
          border-radius: 6px;
          width: 108px;
          height: 36px;
          text-align: center;
          line-height: 30px;
          box-sizing: border-box;
          font-size: 16px;
          // color: #333;
        }

        .btnItem2 {
          border: none;
          border-radius: 6px;
          width: 72px;
          height: 36px;
          text-align: center;
          line-height: 30px;
          box-sizing: border-box;
          font-size: 16px;
        }
      }
    }
  }
}

:deep(.el-table__header) {
  .table-header {
    th {
      font-size: 16px;
      background: #f3f8fb;
      height: 53px;
      color: #6f7070;
      font-weight: normal;
    }
  }
}
</style>
